<?php
/**
 * @author     Thibaut Cromphaut, Gaïtano Boeraeve, Matthias Mercy
 * @copyright  Copyright (c) 2011 memorygame
 */
class Application_Model_UserHasWorldMapper extends Ahs_Model_Mapper
{

    public function __construct(array $options = null)
    {
        parent::__construct($options);
        $this->DbTableName = 'Application_Model_DbTable_UserHasWorlds';
    }
    
    /**
     * UserHasWereld opslaan
     *
     * @param Application_Model_UserHasWorld $userHasWorld
     */
    public function save(Application_Model_UserHasWorld $userHasWorld )
    {
        $data = array(            
            'world_id'              => $userHasWorld->Id,           
            'user_id'               => $userHasWorld->UserId,
            'userHasWorld_score'    => 200,
            'userHasWorld_unlocked' => $userHasWorld->Unlocked,  
        );        

        //if (null == $userHasLevel->Id) {
            //$this->getDbTable()->insert($data); //$userHasLevel->Id         $userHasLevel->UserId
        //} else {  
            $this->getDbTable()->update($data, array('world_id = ?' => $userHasWorld->Id, 'user_id = ?' => $userHasWorld->UserId));
        //}
    }    
}


